package com.LeeCode;

/**
 * 找出克隆二叉树中的相同节点
 */

public class Code1379 {
    public static void main(String[] args) {

    }

    public final TreeNode getTargetCopy(final TreeNode original, final TreeNode cloned, final TreeNode target) {
        if (original == null) return null;
        else if (original.val == target.val) return cloned;
        TreeNode node = getTargetCopy(original.left, cloned.left, target);
        if (node != null) return node;

        // 不在左子树中就在右子树中
        node = getTargetCopy(original.right, cloned.right, target);
        return node;
    }
}
